home *** CD-ROM | disk | FTP | other *** search
/ InterCD 2000 September / september_2000.iso / intercd / root / ^Linux / WindowMaker / src / wmsound.c < prev    next >
Encoding:
C/C++ Source or Header  |  2000-01-18  |  2.1 KB  |  90 lines

  1. #include "wconfig.h"
  2.  
  3. #include <stdio.h>
  4. #include <stdlib.h>
  5. #include <X11/X.h>
  6. #include <X11/Xlib.h>
  7. #include <X11/Xutil.h>
  8. #include <X11/Xproto.h>
  9.  
  10. #include "WindowMaker.h"
  11. #include "funcs.h"
  12. #include "wmsound.h"
  13.  
  14. #ifdef WMSOUND
  15.  
  16.  
  17.  
  18. extern WPreferences wPreferences;
  19.  
  20. #if 0
  21. void
  22. wSoundServerGrab(Window wm_win)
  23. {
  24.     Window    *lstChildren;
  25.     Window    retRoot;
  26.     Window    retParent;
  27.     int        indexCount;
  28.     u_int    numChildren;
  29.     XClassHint    *retHint;
  30.     
  31.     if (XQueryTree(dpy, wm_win, &retRoot, &retParent, &lstChildren, &numChildren)) {
  32.     for (indexCount = 1; indexCount < numChildren; indexCount++) {
  33.         retHint = XAllocClassHint();
  34.         if (!retHint) {
  35.         XFree(lstChildren);
  36.         return;
  37.         }
  38.         
  39.         XGetClassHint (dpy, lstChildren[indexCount], retHint);
  40.  
  41.             if (retHint->res_class) {
  42.                 if (strcmp("WMSoundServer", retHint->res_class)==0 ||
  43.                     /*strcmp("WSoundServer", retHint->res_class)==0 ||*/
  44.                     (retHint->res_name &&
  45.                      strcmp("wsoundserver", retHint->res_name)==0 &&
  46.                      strcmp("DockApp", retHint->res_class)==0)) {
  47.  
  48.                     soundServer = lstChildren[indexCount];
  49.                     XFree(lstChildren);
  50.                     if(retHint) {
  51.                         XFree(retHint);
  52.                     }
  53.                     return;
  54.                 }
  55.         }
  56.         XFree(retHint);
  57.         retHint = 0;
  58.     }
  59.     XFree(lstChildren);
  60.     }
  61.     return;
  62. }
  63. #endif
  64.  
  65. void
  66. wSoundPlay(long event_sound)
  67. {
  68.     static Atom atom = 0;
  69.     XEvent sound_event;
  70.  
  71.     if (!atom) {
  72.     atom = XInternAtom(dpy, "_WINDOWMAKER_EVENT", False);
  73.     }
  74.  
  75.     if(!wPreferences.no_sound) {
  76.     Window win = wScreenWithNumber(0)->info_window;
  77.  
  78.         sound_event.xclient.type = ClientMessage;
  79.         sound_event.xclient.message_type = atom;
  80.         sound_event.xclient.format = 32;
  81.         sound_event.xclient.display = dpy;
  82.         sound_event.xclient.window = win;
  83.         sound_event.xclient.data.l[0] = event_sound;
  84.         XSendEvent(dpy, win, False, StructureNotifyMask, &sound_event);
  85.     XFlush(dpy);
  86.     }
  87. }
  88.  
  89. #endif /* WMSOUND */
  90.